package com.it.day6;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * ClassName: CASDemo
 * Description: CAS演示
 *
 * @Author: csx
 * @Create: 2025/5/12 - 15:13
 * @version: v1.0
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);

        System.out.println(atomicInteger.compareAndSet(5,100) + "\t" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5,200) + "\t" + atomicInteger.get());

        System.out.println(atomicInteger.getAndIncrement());
        System.out.println(atomicInteger.get());
    }
}















